home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_02 / 9n02014a < prev    next >
Text File  |  1991-01-20  |  1KB  |  55 lines

  1. Listing 2
  2.  
  3. /* test limits macros
  4.  * copyright (c) 1991 by P.J. Plauger
  5.  */
  6. #include <limits.h>
  7. #include <stdio.h>
  8.  
  9. /* test basic properties of limits.h macros
  10.  */
  11. int main()
  12.     {
  13. <%-2>#if CHAR_BIT < 8 || CHAR_MAX < 127 || 0 < CHAR_MIN \
  14. <%0>    || CHAR_MAX != SCHAR_MAX && CHAR_MAX != UCHAR_MAX
  15. #error bad char properties
  16. #endif
  17. #if INT_MAX < 32767 || -32767 < INT_MIN \
  18.     || INT_MAX < SHRT_MAX
  19. #error bad int properties
  20. #endif
  21. #if LONG_MAX < 2147483647 \
  22.     || -2147483647 < LONG_MIN \
  23.     || LONG_MAX < INT_MAX
  24. #error bad long properties
  25. #endif
  26. #if MB_LEN_MAX < 1
  27. #error bad MB_LEN_MAX
  28. #endif
  29. #if SCHAR_MAX < 127 || -127 < SCHAR_MIN
  30. #error bad signed char properties
  31. #endif
  32. #if SHRT_MAX < 32767 || -32767 < SHRT_MIN \
  33.     || SHRT_MAX < SCHAR_MAX
  34. #error bad short properties
  35. #endif
  36. #if UCHAR_MAX < 255 || UCHAR_MAX <= 2 * SCHAR_MAX
  37. #error bad unsigned char properties
  38. #endif
  39. #if UINT_MAX < 65535 || UINT_MAX <= 2 * INT_MAX \
  40.     || UINT_MAX < USHRT_MAX
  41. #error bad unsigned int properties
  42. #endif
  43. <%4>#if ULONG_MAX < 4294967295 \
  44.     || ULONG_MAX <= 2 * LONG_MAX \
  45. <%0>    || ULONG_MAX < UINT_MAX
  46. #endif
  47. <%-2>#if USHRT_MAX < 65535 || USHRT_MAX <= 2 * SHRT_MAX \
  48. <%0>    || USHRT_MAX < UCHAR_MAX
  49. #error bad unsigned short properties
  50. #endif
  51.     puts("SUCCESS testing <limits.h>");
  52.     return (0);
  53.     }
  54.  
  55.